import axios from "axios";

// 创建 Axios 实例
const instance = axios.create({
    baseURL: '/api',
    timeout: 10000,
    headers: {
        'X-Custom-Header': 'foobar',
        'Content-Type': 'application/json'
    }
});

export const  getBooks =async () => {
    try {
        const response = await instance.get('/getBooks')
        console.log('接口返回数据:', response.data);
        return response.data;
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}
export const  updateBook =async (bookDate) => {
    try {
        const response = await instance.post('/updateBook',bookDate);
        console.log('接口返回数据:', response.data.list);
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}
export const  addBook =async (BookData) => {
    try {
        await instance.post('/insertBook',BookData)
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}
export default instance;